This arrangement is designed to facilitate printing of the entire topic. Some duplication of references, link headers, and "Related Topics" information may be observe.
How To Support LDAP Server Entries Through Data Services
Prefer all related topics on a single page? Click here.
AquaLogic Data Services Platform (ALDSP) enables you to create physical data services based on Java functions. The example described in this topic focuses on creating a physical data service based on a set of functions that can access and update entries in an LDAP server.
Specifically, the example:
Shows how to build and test a sample application configured to work, by default, with the LDAP server embedded in WebLogic server.
Provides step-by-step instructions for creating the physical data service based on the Java functions.
Shows how to create an operation in a logical data service to test the physical data service against the embedded LDAP server.
The sample application, located in the DspLdapWrapper.java file, contains the following Java functions that you can use to create corresponding operations in a physical data service:
Java Function
Description
createPerson()
Create an entity for a person on the LDAP server.
deletePerson()
Remove a person from the LDAP server.
getAllPersons()
Retrieve all persons in the LDAP server.
getPersonByUserId()
Retrieve a record from the LDAP server identified by the specific ID.
updatePersonSDO()
Update a record on the LDAP service using SDO.
updatePersonXMLBean()
Update a record on the LDAP service using XMLBeans.
Working with the Sample Application
Working with the sample application to create the physical data service involves the following steps:
Create the sample application.
This involves setting up your Ant environment, editing the build.properties file, configuring the WebLogic embedded LDAP server, and building the Java application.
This topic describes how to build the LDAP sample Java application, ldap_java.jar. The functions in the application can then be used as the basis for a data service.
In order to run this sample you must have ALDSP 3.2 or 3.01 installed and have downloaded and opened the LDAP sample file. The file can be obtained at:
Type the following value in the Credential and Confirm Credential fields:
secret
Click Save > Activate Changes
The Activate Changes option is only active if you are changing the default credential password.
Restart your ALDSP server.
Configuring the Sample Application to Use an Alternative LDAP Server
The sample application is configured to use the WebLogic embedded LDAP server. You can, however, use the sample application with any LDAP server that has a Distinguished Name (DN) with a list of inetOrgPerson instances.
To configure the sample application to use an alternative LDAP server:
Open the springldap.xml file.
You can find the springldap.xml file in the following directory:
If you have not already done so, install the ALDSP Retail Dataspace Sample. The sample creates a dataspace for retail data services that connects to a relational database and web services.
Depending on whether your are running WebLogic server 10.1 or 9.2 see:
Two separate import operations into the Retail Dataspace project are needed.
Import Source
Contents
Spring LDAP 1.2.1 JAR
Basic LDAP support classes.
ldap_java.jar
Java functions needed by the new physical data service.
If you have not already done so, unzip the project ZIP file LdapJavaDsp32.zip into a temporary directory. The project files are located in the LdapJavaDsp32 directory.
Importing Spring LDAP JAR Files
To import the Spring LDAP JAR files which were included with the LDAP sample:
Expand the Retail Dataspace project and locate the DSP-INF/lib folder.
Project Explorer - DSP-INF/lib Folder
Right-click the DSP-INF/lib folder and choose Import.
Select General > File System and click Next.
Import Source Dialog
For the From directory field click Browse, select the LdapJavaDsp32/lib folder, and click OK.
Importing the Spring LDAP JAR Files
Click the checkbox next to lib to select all JAR files in the library; then click Finish. The wizard imports the selected JAR files.
Importing the ldap_java.jar File
The ldap_java.jar file contains Java functions for your new physical data service.
To import the ldap_java.jar file:
Right-click the DSP-INF/lib folder and choose Import.
Select General > File System, then Next.
For the From directory field click Browse, select the LdapJavaDsp32/dist folder, and click OK.
Importing the ldap_java.jar File
Click the checkbox next to dist, then click Finish. The wizard imports the ldap_java.jar file.
Creating the Physical Data Service
You need to create the physical data service that uses Java functions to facilitate data access.
You can inspect the Java functions; they are in the DspLdapWrapper.java file.
To create the physical data service:
In the Project Explorer right-click RetailDataspace/Physical, and choose New > Physical Data Service.
Creating a New Physical Data Service
Choose Java Function from the Data source type drop-down list.
Click Browse next to the Class name field. The Open Java Class dialog appears.
Navigate to:
ldap_java/com/example/ldap/DspLdapWrapper.class
Click Open.
Open Java Class
Click Next.
Select all functions except:
{{main(java.lang.String)}}
Select the updatePersonSDO() function
Select the With Change Summary checkbox.
Select Java Function
Click Next.
Configure the settings in the Review New/Updated Data Service Operation(s) step, as shown in the following table:
Operation
Public
Kind
Primary
updatePersonXMLBean
Yes
Update
updatePersonSDO
Yes
Update
deletePerson
Yes
Delete
Yes
createPerson
Yes
Create
Yes
getPersonByUserId
Yes
Read
getAllPersons
Yes
Read
Review New/Updated Data Service Operation(s)
Click Next.
Type a Data Service Name, such as:
LDAPdsp
Click Finish.
Update the Procedure Declaration
The procedure declaration generated by the New Physical Data Service Wizard needs to be modified.
This step is a workaround for CR365986 in the import wizard. Once you make these code changes to correctly list inetOrgPerson it will work correctly and will treat the function as a primary update procedure.
To update the procedure declaration:
Double-click the data service in the Project Explorer.
Click the Source tab.
Update the pragma of the updatePersonSDO() procedure to set the operation as primary, as shown in the following:
Update the declaration for the updatePersonSDO() procedure to match the following (make sure the namespace prefix matches your source):
declare procedure f1:updatePersonSDO($x1 as changed-element(t1:inetOrgPerson)*) as empty() external;
Choose File > Save from the main menu.
Redeploy the project.
You can now perform create, read, update and delete (CRUD) operations against an LDAP server. For example, in Test view you can run the getAllPersons() operation.
Testing the getAllPersons() LDAP Operation
You can also optionally create new logical data services that combine this physical data service with other data services, such as RDBMS, Web Services, and so on.
The first step is to create a new logical data service that will serve as the container for the operation.
Expand RetailDataspace/Logical, right-click Customer, and choose New > Logical Data Service.
Choosing New > Logical Data Service
Enter LdapTest as the data service name.
New Logical Data Service Dialog
Click Browse to select a schema file, expand Logical/Customer/schemas, select Profile.xsd, and click OK.
New Dataspace Project Dialog
Click Finish. Studio creates the new logical data service.
Creating a Read Operation
After creating the logical data service, you need to add a read operation that uses the Java-based read operation in the physical data service.
In the Overview for the LDAPTest.ds data service, right-click and choose Add Operation.
Adding a New Operation
Type a name for the new operation, such as getLdapCustomers.
Click OK.
Adding a New Operation Dialog
Choose File > Save to save the data service.
Defining the Read Operation
The next step is to define the getLdapCustomers read operation to join information returned by the getAllPersons Java-based operation and the getCustomer operation in the Profile data service.
Click the Query Map tab in the LdapTest.ds data service.
Expand RetailDataspace/Physical/LDapdsp.ds, drag the getAllPersons() operation, and drop it in the Query Map.
Adding the getAllPersons Operation
Expand RetailDataspace/Logical/Customer/Profile.ds, drag the getCustomer operation, and drop it in the Query Map.
Adding the getCustomer Operation
Create a connection between the userId element in the getAllPersons() operation and the LoginID element in the getCustomer operation by dragging the userId element to the target element.
Joining the userId and LoginID
Click the Overwrite Mapping button, and drag the PROFILE complex element name in the getCustomer operation to the PROFILE element in the Return type.
Overwrite Mapping the Porfile to the Return Results
Right-click PROFILE in the Return result and choose Expand Complex Mapping.
Expanding Complex Mapping
Click the Source tab.
Change the FirstName element of the result to the following: